<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    
    function Person(name, age) {
      this.name = name;
      this.age = age;
 
      // this.eat = function() {
      //   console.log(`${this.name}在吃`);
      // }

    }

    // 构造函数有自己的原型对象
    // 可以把每一个实例都要共用的属性和方法(重点)添加到构造函数的原型对象中
    Person.prototype.eat = function() {
      console.log(`${this.name}在吃`);
    }

    const man = new Person('张三', 18);
    const woman = new Person('丽丽', 28);
    // console.log(man, woman);
    // console.log(man === woman)

    man.eat();
    woman.eat();

    console.log(man.eat === woman.eat) // false
  </script>
</body>
</html>